# Contributor: Andy Postnikov <apostnikov@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>

pkgname=php7-pecl-uploadprogress
_pkgreal=uploadprogress
pkgver=1.1.3
pkgrel=2
pkgdesc="An extension to track progress of a file upload for PHP"
url="https://pecl.php.net/package/uploadprogress"
arch="all"
license="PHP-3.01"
depends="php7-common"
makedepends="php7-dev re2c"
subpackages="$pkgname-doc::noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/php/pecl-php-uploadprogress/archive/uploadprogress-$pkgver.tar.gz"
builddir="$srcdir/pecl-php-uploadprogress-uploadprogress-$pkgver"
provides="php7-uploadprogress=$pkgver-r$pkgrel" # for backward compatibility
replaces="php7-uploadprogress" # for backward compatibility

build() {
	phpize7
	./configure \
		--prefix=/usr \
		--with-php-config=php-config7
	make
}

check() {
	php7 -d extension="$builddir"/modules/$_pkgreal.so --ri $_pkgreal
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	local confdir="$pkgdir/etc/php7/conf.d"
	mkdir -p "$confdir"
	echo "extension=$_pkgreal.so" > "$confdir"/$_pkgreal.ini

	local docdir="$pkgdir"/usr/share/doc/$pkgname
	install -Dm644 -t $docdir README.md
	install -Dm644 -t $docdir/examples examples/*
}

sha512sums="7c5e58ab113d52da138d0518292f8bfb0597fd7ac5b43bef4954239020670a89fc616957d1ac43dae6660752ff0b396388aff26979b989b7768927fddefea7c0  php7-pecl-uploadprogress-1.1.3.tar.gz"
